﻿using AutoMapper;
using FFLTask.SRV.ViewModel.Account;
using Entity = FFLTask.BLL.Entity;
using FFLTask.SRV.ProdService.ViewModelMap.Helper;
using Global.Core.ExtensionMethod;

namespace FFLTask.SRV.ViewModelMap.AccountMap
{
    internal class UserModelMap
    {
        internal static void init()
        {
            Mapper.CreateMap<Entity.User, UserModel>()
                .ForMember(u => u.HasLogon, opt => opt.UseValue(true))
                .ForMember(u => u.HasJoinedProject, 
                    opt => opt.MapFrom(x => !x.Authorizations.IsNullOrEmpty()))
                .IgnoreAllNonExisting()
                ;
        }
    }
}
